<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>



<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.users.Functionality" %>


<html:html><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>


<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</SCRIPT>

<script language="javascript">
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}
function wipFlush()
{
    var form = document.wipFlushForm;
    var date = form.workWeek;
	var error	= document.getElementById( "errors" );
	var errorMsg1 = "";

	if( date[0].checked == true && date[0].disabled == false )
	{
		errorMsg1 = checkWeeks();
	}

    if( errorMsg1.length > 0 )
	{
		error.innerHTML	= errorMsg1;
	}
	else
	{
	    document.wipFlushForm.submit();
	}
}

function selectedBaseProduct()
{
    var form = document.wipFlushForm;
    var partNumbersCtrl = form.fgProcessStepIds;
    partNumbersCtrl.selectedIndex = 0;
}
function selectedPartNumber()
{
    var form = document.wipFlushForm;
    var baseProcuctssCtrl = form.baseProductIds;
    baseProcuctssCtrl.selectedIndex = 0;
}
function disableAllocation()
{
    var error	= document.getElementById( "errors" );
    error.innerHTML = '';

    var allocation = document.wipFlushForm["allocation"];
    var date = document.wipFlushForm["workWeek"];

    if( allocation[0].checked == true )
	{
        for( var i = 0 ; i < 2 ; i++ )
		{
            date[i].disabled = true;
        }
		document.wipFlushForm.noOfWeeks.disabled=true;
		document.wipFlushForm.noOfWeeks.value=6;
    }
	else
	{
        for( var i = 0 ; i < 2 ; i++ )
		{
            date[i].disabled = false;
        }

		if( date[0].checked == true )
		{
			document.wipFlushForm.noOfWeeks.disabled=false;
		}
    }
}

function enableWeeks()
{
    var date = document.wipFlushForm["workWeek"];

	if( date[0].checked == true )
	{
		document.wipFlushForm.noOfWeeks.disabled=false;
	}
	else
	{
		document.wipFlushForm.noOfWeeks.disabled=true;
	}
}

function checkWeeks()
{
	document.wipFlushForm.noOfWeeks.value = document.wipFlushForm.noOfWeeks.value.trim();
	var weekVal = document.wipFlushForm.noOfWeeks.value;
	var error	= document.getElementById( "errors" );
	var errorMsg1 = "";

	if( weekVal.length != null && weekVal.length > 0 )
	{
		if( checkInteger ( weekVal, 'No of weeks', 'N' ) == false )
		{
			errorMsg1 = errorMsg1 + "<li>" + errMsg + "</li>" ;
		}
	}

	if( errorMsg1.length <= 0 && weekVal.length != null && weekVal.length > 0 )
	{
		if( weekVal > 26 )
		{
			errorMsg1 = errorMsg1 + "No of weeks cannot be more than 26";
		}
		else if ( weekVal < 6 )
		{
			errorMsg1 = errorMsg1 + "No of weeks cannot be less than 6";
		}
	}

	error.innerHTML		= errorMsg1 ;
	return errorMsg1;
}

function resetWindow()
{
	var form = document.wipFlushForm;
	form.mainGroup[0].checked = true;
	form.allocation[0].checked = true;
	form.holdLot[0].checked = true;
	form.workWeek[0].checked = true;
	form.workWeek[0].disabled = true;
	form.workWeek[1].disabled = true;
	form.noOfWeeks.disabled = true;
	form.level[0].checked = true;
}

</script>



</HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/operations/reports_side_menu.jsp" %>
<!-- end of the side navigations -->
</TD>

<TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>


<!-- Start : Wip Flush -->

<html:form name="wipFlushForm" action="/wipFlush" method="post" type="com.scalar.chiptrack.operations.reports.forms.WipFlushForm">

<TABLE width="100%" border="0">
    <TBODY>
        <TR>
    		<TD valign="top" bgcolor="#ffffff" width="5%">
				<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8">
            </TD>
			<TD valign="top" width="95%" nowrap align="center">
                <table border="0">
                    <tr>
                        <td COLSPAN="7" CLASS="NArialW" ALIGN="CENTER">Wip Flush Report</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
						<td class="NArialL" colspan="7" align="right">
                            <chiptrack:restrictedLink functionality='<%=Functionality.WIP_FLUSH%>' styleClass="leftsection" href="/chiptrack/wipFlush.do?action=CalculateWipFlush" onmouseover="window.status='Click for Wip Flush Report';return true" onmouseout="window.status='';return true">
                            Generate Wip Flush Calculations
                            </chiptrack:restrictedLink>
                        </td>
					</tr>
                    <tr>
						<td colspan="7" class="NArialL"><FONT id="errors" color="FF0000"></FONT>
                            <chiptrack:info styleClass='NArialL'/>
                            <chiptrack:errors styleClass='NArialL'/>
                        </td>
					</tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Base Product </td>
                        <td>&nbsp;</td>
                        <td class="NArialL" colspan="2">
                            <nested:select property="baseProductIds" multiple="true" size="6" styleClass="txfield" style="width:200px" onclick="selectedBaseProduct()">
                                <html:option value="0">All Base Products</html:option>
                                <html:options collection="baseProducts" property="value" labelProperty="label"/>
                            </nested:select>
                        </td>
                        <td bgcolor="#CDCEE9" class='NArialL'><bean:message key="label.mktgPartNumber"/></td>
                        <td>&nbsp;</td>
                        <td class="NArialL">
                            <nested:select property="fgProcessStepIds" multiple="true" size="6" styleClass="txfield" style="width:200px" onclick="selectedPartNumber()">
                                <html:option value="0">All Part Numbers</html:option>
                                <html:options collection="mktPartNumberList" property="value" labelProperty="label"/>
                            </nested:select>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Main Grouping</td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="mainGroup" id="pn" value="product" checked><label for="pn">Part Number</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="mainGroup" id="vn" value="vendor"><label for="vn">Vendor Name</label></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Allocation</td>
                        <td>&nbsp;</td>
                        <td  class="NArialL"><input type="radio" name="allocation" id="inv" value="all" checked onclick="javascript:disableAllocation()"><label for="inv">Inventory</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="allocation" value="shippable" id="shpbl" onclick="javascript:disableAllocation()"><label for="shpbl">Shippable</label></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Lots</td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="holdLot" id="all" value="1" checked ><label for="all">All</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="holdLot" id="woh" value="2"><label for="woh">With Out Hold</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="holdLot" id="wh" value="3"><label for="wh">With Hold</label></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Date</td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="workWeek" id="week" value="weekDate" checked disabled onclick="javascript:enableWeeks()"> <label for="week">F/G Date WW</label></td>
                        <td>&nbsp;</td>
                        <td  class="NArialL"><input type="radio" name="workWeek" id="month" value="monthDate" disabled onclick="javascript:enableWeeks()"><label for="month">F/G Date Month</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><label for="now">No of weeks</label><input type="text" name="noOfWeeks" id="now" value="6" class="txfield" size="4" maxlength="2" disabled onkeypress="javascript:allowInteger()"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td bgcolor="#CDCEE9" class='NArialL'>Levels</td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="level" id="cal" value="collapseAll" checked><label for="cal">Collapse All Levels</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="level" id="eol"value="expandOneLevel" ><label for="eol">Expand One Level</label></td>
                        <td>&nbsp;</td>
                        <td class="NArialL"><input type="radio" name="level" id="eal" value="expandAll" ><label for="eal">Expand All Levels</label></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td colspan="7" align="center">
                            <a href="javascript:wipFlush();" onMouseOver="window.status='Click to Generate Report';return true" onMouseOut="window.status='';return true" title="Click here to Generate Report"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17"></a>

                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <a href="javascript:resetWindow();" onMouseOver="window.status='Click to Reset';return true" onMouseOut="window.status='';return true" title="Click here to Reset">
                                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17">
                            </a>
                        </td>
                    </tr>
                </table>
            </TD>
        </TR>
    </TBODY>
</TABLE>
</html:form>

<!-- End : Wip Flush -->

<BR><BR><BR>
</TD>

<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</html:html>
